package demo2;

public class Test {
    //深拷贝
    public static void main(String[] args) throws CloneNotSupportedException{
        Person person1 = new Person("zhangsan",18,70);

        Person person2 = (Person)person1.clone();

        System.out.println(person1.H.height);
        System.out.println(person2.H.height);

        System.out.println("----------");
        person2.H.height = 180;

        System.out.println(person1.H.height);
        System.out.println(person2.H.height);


    }

    //浅拷贝
    public static void main1(String[] args) throws CloneNotSupportedException{
        Person person1 = new Person("lisi",20,90);

        Person person2 = (Person)person1.clone();

        System.out.println(person2);

    }
}
